<template>
	<view class="u-padding-20">
		<view class="list_con u-flex u-row-between" v-if="status==1">
			<text class="title_con">借领详情</text>
			<block v-if="detail.is_examine==0">
				<text class="status_con">待审批</text>
			</block>
			<block v-else-if="detail.is_examine==1">
				<text class="status_con" v-if="detail.status==0">待审核</text>
				<text class="status_con" v-else-if="detail.status==1">审核通过</text>
				<text class="status_con" v-else>审核拒接</text>
			</block>
			<block v-else>
				<text class="status_con">审批未通过</text>
			</block>
		</view>
		
		<!-- <view class="list_con u-flex u-row-between">
			<text>订单号</text>
			
		</view> -->
		<view class="list_con u-flex u-row-between">
			<text>选择使用方式</text>
			<text v-if="detail.type==2">取用物资</text>
			<text v-else>领用物资</text>
		</view>
		<view class="list_con u-flex u-row-between">
			<text>资产名称</text>
			<text>{{detail.name}}</text>
		</view>
		<view class="list_con u-flex u-row-between">
			<text>借领数量</text>
			<text>{{detail.num}}</text>
		</view>
		<view v-if="detail.nav" class="list_con u-flex u-row-between">
			<text>物品类型</text>
			<text>{{detail.nav}}</text>
		</view>
		<view class="list_con u-flex u-row-between">
			<text>预约时间</text>
			<text>{{detail.time}}</text>
		</view>
		<!-- <view class="list_con u-flex u-row-between">
			<text>借领人头像</text>
			<u-avatar :src="detail.avatar" mode="circle" size="60"></u-avatar>
		</view> -->
		<view class="list_con u-flex u-row-between">
			<text>借领人</text>
			<text>{{detail.username}}</text>
		</view>
		<view class="list_con u-flex u-row-between">
			<text>申请日期</text>
			<text>{{$u.timeFormat(detail.create_time, 'yyyy-mm-dd')}}</text>
		</view>
		<view class="list_con u-flex u-row-between">
			<text class="title_con">物品信息</text>
			<text class="status_con"></text>
		</view>
		<view class="list_con u-flex u-row-left">
			<image :src="detail.image" mode="aspectFill"></image>
			<view class="list_con" style="width:70%;border:none">
				<view>{{detail.name}}</view>
				<text style="color:#666;margin:10rpx 0;display: block;">数量：{{detail.num}}</text>
				<text class="dis_blo title_con">单价：￥{{detail.unit}}</text>
			</view>
		</view>
		<view class="list_con" style="border:none;">
			<text>物品用途</text>
			<view>{{detail.label}}</view>
		</view>
		<block v-if="type==1 || type==2">
			<view v-if="detail.is_examine==0" style="margin-top:100rpx;" class="u-padding-15 u-text-center">
				<u-button class="u-margin-right-50" type="success" shape="circle" @click="toapprove(1)" size="medium">审批通过</u-button>
				<u-button type="default" shape="circle" @click="toapprove(-1)" size="medium">审批拒接</u-button>
				
			</view>
		</block>
		
		<view v-if="detail.is_examine==1 && detail.status==0" style="margin-top:100rpx;" class="u-padding-15 u-text-center">
			<u-button class="u-margin-right-50" type="success" shape="circle" @click="torelease(1)" size="medium">审核通过</u-button>
			<u-button type="default" shape="circle" @click="torelease(-1)" size="medium">审核拒接</u-button>
			
		</view>
		<!-- 审核 -->
		<u-modal v-model="showmodal" :mask-close-able="true" confirm-color="#008987"
		:show-cancel-button="true" :content="content" @confirm="confirm"></u-modal>
		<!-- 审批 -->
		<u-modal v-model="showapprove" :mask-close-able="true" confirm-color="#008987" :show-cancel-button="true"
		 :content="approvecontent" @confirm="confirmapprove"></u-modal>
		
	</view>
</template>

<script>
	import cookie from "@/util/store/cookie";
	import {
		assetsExamine,approve
	} from "@/service/assetService.js";
	export default {
		data () {
			return {
				id:0,
				type:1,
				title:'借用详情',
				status:1,
				detail:{},
				showmodal:false,
				content:'您确认给予该条信息审核通过？',
				isexamine:1,
				showapprove:false,
				approvecontent:'您确认给予该条信息审批通过？'
			}
		},
		onLoad(options) {
			this.type=cookie.get('type')
			let item=JSON.parse(decodeURIComponent(options.item));
			this.id=item.id;
			this.detail.id=item.id;
			this.detail.name=item.name;
			this.detail.num=item.num;
			this.detail.unit=item.unit;
			this.detail.price=item.price;
			this.detail.label=item.label;
			this.detail.time=item.time;
			this.detail.image=item.image;
			this.detail.create_time=item.create_time;
			this.detail.nid=item.nid;
			this.detail.status=item.status;
			this.detail.type=item.type,
			this.detail.avatar=item.avatar,
			this.detail.username=item.username,
			this.detail.nav=item.nav,
			this.detail.revert=item.revert
			this.detail.is_examine=item.is_examine
			// console.log(this.detail)
		},
		methods:{
			torelease(i){
				this.showmodal=true
				if(i==1){
					this.content="您确认给予该条信息审核通过？"
					this.status=1
				}else{
					this.content="您确认给予该条信息审核拒接？"
					this.status=-1
				}
			},
			toapprove(i){
				this.showapprove=true
				if(i==1){
					this.content="您确认给予该条信息审批通过？"
					this.isexamine=1
				}else{
					this.content="您确认给予该条信息审批拒接？"
					this.isexamine=-1
				}
			},
			
			confirm(){
				assetsExamine({
					id:this.id,
					status:this.status
				}).then(res=>{
					if(res.code==200){
						this.$refs.uToast.show({
							type: 'success',
							title: '处理成功',
							icon:false
						})
						setTimeout(function(){
							uni.navigateBack()
						},1000)
						
					}else{
						this.$refs.uToast.show({
							type: 'error',
							title: res.msg,
							icon:false
						})
					}
				})
			},
			confirmapprove(){
				approve({
					id:this.id,
					is_examine:this.isexamine
				}).then(res=>{
					if(res.code==200){
						this.$refs.uToast.show({
							type: 'success',
							title: '审批成功',
							icon:false
						})
						this.current=0;
						getAssetsLogList({type:99}).then(this.getAssetsLogList)
					}else{
						this.$refs.uToast.show({
							type: 'error',
							title: res.msg,
							icon:false
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.list_con{
		padding:20rpx 0;
		border-bottom:1rpx solid #ddd;
	}
	.list_con text:first-child{
		color:#666;
	}
	.list_con .title_con{
		color:#333 !important;
		font-size: 32rpx;
		font-weight: bold;
	}
	.status_con{
		font-size: 28rpx;
		color:#008987;
	}
	.list_con image{
		width:150rpx;
		height:150rpx;
		margin:0 20rpx;
		border-radius: 20rpx;
	}
	.imgvideo{
		display: block;
		margin-top:60rpx;
		margin-bottom:30rpx;
		border:1rpx solid #008987;
		border-radius: 30rpx;
		overflow: hidden;
	}
	.imgvideo text{
		display: inline-block;
		height:60rpx;
		width:50%;
		color:#008987;
		text-align: center;
		line-height: 60rpx;
	}
	.imgvideo .video_title{
		color:#fff;
		background-color: #008987;
	}
	.warp {
		display: flex;
		align-items: flex-end;
		justify-content: center;
		height: 100%;
	}
	
	.rect {
		width: 100%;
		height: 300px;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		background-color: #fff;
	}
	.shadow_con{
		padding:80rpx 20rpx;
	}
	.shadow_con input{
		width:93%;
		height:70rpx;
		padding:0 20rpx;
		margin-bottom:30rpx;
		border-radius: 10rpx;
		border:1rpx solid #ccc;
		background-color: #fcfcfc;
	}
	.btn_con{
		height:70rpx;
		line-height: 70rpx;
		font-size: 30rpx;
		border-radius: 35rpx;
		background-image: url('https://resourse.cnlhjt.com/upload/20220825/d1aa35c1d129137d9b12c8f34e59c5bc.png');
		background-size: 100% 70rpx;
		color:#fff;
		margin-top:50rpx;
	}
</style>
